import $http from '@/service/request.js'

//功能：获取用户实验室信息
//接口：/users/laboratory
//POST
export const _labomanage = ({account_user}) =>{
	return $http.request({
		url:'/users/laboratory',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user
		}
	})
}

//功能：查询用户账号user(实验室使用者)实验室
//接口：/lab/findLab
//POST
export const _laboInfo = ({user}) =>{
	return $http.request({
		url:'/lab/findLab',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			user
		}
	})
}

//功能：根据账号查询被共享的实验室
//接口：/lab/findMessage
//GET
export const _getSharedLabInfo = ({isRead,receiver}) =>{
	return $http.request({
		url:'/lab/findMessage',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			isRead,
			receiver
		}
	})
}

//功能：根据实验室名称查询使用者
//接口：/lab/findLabByName
//GET
export const _searchLabByName = ({name}) =>{
	return $http.request({
		url:'/lab/findLabByName',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			name
		}
	})
}

//功能：拒绝共享实验室
//接口：/lab/refuseSharing
//POST
export const _refuseSharedLab = ({id,owner,user,name}) =>{
	return $http.request({
		url:'/lab/refuseSharing',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			id,
			owner,
			user,
			name
		}
	})
}

//功能：接受共享实验室邀请
//接口：/lab/acceptSharing
//POST
export const _acceptSharedLab = ({id,owner,user,name}) =>{
	return $http.request({
		url:'/lab/acceptSharing',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			id,
			owner,
			user,
			name
		}
	})
}

//功能：取消某实验室的共享（共享与被共享者均可操作）
//接口：/lab/deleteSharing
//DELETE
export const _cancelSharedLab = ({name,user}) =>{
	return $http.request({
		url:'/lab/deleteSharing',
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			name,
			user,	
		}
	})
}

//功能：邀请用户共享实验室
//接口：/lab/inviteSharing
//POST
export const _inviteSharedLab = ({id,owner,user,name}) =>{
	return $http.request({
		url:'/lab/inviteSharing',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			id,
			owner,
			user,
			name
		}
	})
}

//功能：根据该实验室拥有者的实验室id查询使用该实验室的使用者
//接口：/lab/findUserById
//GET
export const _searchSharedLabById = ({ownerId}) =>{
	return $http.request({
		url:'/lab/findUserById',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			ownerId
		}
	})
}

//功能：查询收到的邀请共享实验室
//接口：/lab/findInvite
//GET
export const _searchReceivedSharedLab = ({receiver,type,isRead}) =>{
	return $http.request({
		url:'/lab/findInvite',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			receiver,
			type,
			isRead
		}
	})
}

//功能：根据实验室名称和实验室拥有者查询共享人数
//接口：/lab/findShareCount
//GET
export const _searchLabSharedNum = ({name,owner}) =>{
	return $http.request({
		url:'/lab/findShareCount',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			name,
			owner
		}
	})
}
//根据该实验室拥有者的实验室id查询使用该实验室的使用者
//接口：/lab/findUserById
//GET
export const _findUserById = (ownerId) =>{
	return $http.request({
		url:'/lab/findUserById?ownerId='+ownerId,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}